import { _decorator, Component, Label, Node } from 'cc';
import AbstractComponent from '../../../base/AbstractComponent';
import { BallInfoNode } from './BallInfoNode';
import { App } from '../../../App';
import { GameModel2 } from './GameModel2';
import { Ball } from '../Ball';
import GameUtils2 from './GameUtils2';
import { find } from 'cc';
import { UITransform } from 'cc';
import { view } from 'cc';
import UtilTool from '../../../tools/UtilTool';
const { ccclass, property } = _decorator;

@ccclass('GameTrainFail')
export class GameTrainFail extends AbstractComponent {
    @property(Node)
    bg : Node = null
    
    start() {
        App.Audio.playOneShot("game/fail")
    
        this.node.getComponent(UITransform).setContentSize(view.getVisibleSize())
        UtilTool.nodeActive(this.bg, 5)
    }

    onBtnAgain() {
        App.Audio.playOneShot("click");
        (App.Model.gameView as GameModel2).gameLogic.restart()
        this.node.destroy();
    }

    onBtnOk() {
        App.Audio.playOneShot("click")
        this.node.destroy();
        (App.Model.gameView as GameModel2).gameLogic.exitGame()
        this.backToHall()
    }

}
